package com.hbx.platform.base.listener;

import com.hbx.platform.base.service.IAutoPermissionService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

/**
 * @author: hbx
 * @date: 2024/04/07
 **/
@WebListener //交给IOC容器
public class InitPermissionListener implements ServletContextListener {

    @Autowired
    private IAutoPermissionService autoPermissionService;

    /**
     * 初始化执行
     * @param sce
     */
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        System.out.println("容器初始化开始---------------------");
        //更新权限表
        autoPermissionService.AutoInit();
        System.out.println("容器初始化结束---------------------");
    }

    /**
     * 销毁执行
     * @param sce
     */
    @Override
    public void contextDestroyed(ServletContextEvent sce) {

    }
}
